@extends('layouts.admin.master')

@section('content')
    @include('kindeditor.head')
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <br/>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        编辑品牌
                    </div>
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        @include('admin.common.errors')
                        <form class="form-horizontal" role="form" method="post"
                              action="{{ route('admin.brands.update',['id' => $brand->id]) }}">
                            {{ csrf_field() }}
                            {{ method_field('PATCH') }}
                            <input type="hidden" name="id" value="{{ $brand->id }}">
                            <div class="form-group">
                                <label for="inputName" class="col-sm-2 control-label">品牌名称</label>

                                <div class="col-sm-4">
                                    <input type="text" name="name" class="form-control" id="inputName"
                                           value="{{ old('name', $brand->name) }}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">品牌图片</label>

                                <div class="col-sm-4">
                                    <img src="{{ old('image', $brand->image) ? old('image', $brand->image) : asset('img/nopic.gif') }}"
                                         style="border:1px solid #ddd;width:160px;height:100px">
                                    <br/>
                                    <input name="image" type="text" id="url1" value="{{ old('image', $brand->image) }}"/> <input
                                            type="button" id="image1"
                                            value="选择图片"/>
                                    <script type="text/javascript">
                                        KindEditor.ready(function (K) {
                                            var editor = K.editor({
                                                allowFileManager: true,
                                                uploadJson: '{{ route('kindeditor.store') . '?type=brand' }}',
                                                extraFileUploadParams: {_token: '{{ csrf_token() }}'}
                                            });
                                            K('#image1').click(function () {
                                                editor.loadPlugin('image', function () {
                                                    editor.plugin.imageDialog({
                                                        showRemote: false,
                                                        imageUrl: K('#url1').val(),
                                                        clickFn: function (url, title, width, height, border, align) {
                                                            K('#url1').val(url);
                                                            editor.hideDialog();
                                                        }
                                                    });
                                                });
                                            });
                                        });
                                    </script>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="txtBrief" class="col-sm-2 control-label">品牌简介</label>

                                <div class="col-sm-6">
                                    <textarea id="txtBrief" name="brief" class="form-control"
                                              rows="6">{{ old('brief', $brand->brief) }}</textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <button type="submit" class="btn btn-default">确认</button>
                                </div>
                            </div>
                        </form>
                        <!-- /.form-horizontal -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
    </div>
@endsection